<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="修改贷款信息表" bodyClass="white-bg" libs=["prism","bootstrapSelect","ueditor"] />
<div class="wrapper wrapper-content ibox-content">
    <@form.form id="form-loan-edit"  class="form-horizontal">
    <input name="id" value="${bpmCrmLoan.id}" type="hidden">
    <div class="form-group">
        <label class="col-sm-3 control-label"><@ctx.i18n text = "销售员" />：                
       </label>
        <div class="col-sm-8"><input name="saleUserid" value="${bpmCrmLoan.saleUserid?default("")}" class="form-control" type="text" >                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "销售订单编号" />：                               <i class="fa fa-question-circle-o" title="销售订单编号"></i>                                
       </label>
        <div class="col-sm-8"><input name="saleOrderNumber" value="${bpmCrmLoan.saleOrderNumber?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "车辆识别号" />：                               <i class="fa fa-question-circle-o" title="车辆识别号"></i>                                
       </label>
        <div class="col-sm-8"><input name="outCarVin" value="${bpmCrmLoan.outCarVin?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "车型" />：                               <i class="fa fa-question-circle-o" title="车型"></i>                                
       </label>
        <div class="col-sm-8"><input name="outCarVehicle" value="${bpmCrmLoan.outCarVehicle?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "申请贷款金额" />：                               <i class="fa fa-question-circle-o" title="申请贷款金额"></i>                                
       </label>
        <div class="col-sm-8"><input name="loanApplyMoney" value="${bpmCrmLoan.loanApplyMoney?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "申请备注"/>：</label>
        <div class="col-sm-8">
            <textarea name="loanApplyMemo" class="form-control" required>${bpmCrmLoan.loanApplyMemo?default("")}</textarea>
        </div>
    </div>
               
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "贷款专员审核"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="loanSpecialistReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmLoan.loanSpecialistReview?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "合同文件" />：                               <i class="fa fa-question-circle-o" title="合同文件"></i>                                
       </label>
        <div class="col-sm-8"><input name="loanContractFilepath" value="${bpmCrmLoan.loanContractFilepath?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "贷款金额" />：                               <i class="fa fa-question-circle-o" title="贷款金额"></i>                                
       </label>
        <div class="col-sm-8"><input name="loanMoney" value="${bpmCrmLoan.loanMoney?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "职称专员流程"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="loanTitleSpecialistProcess" dictType="sys_bpm_crm_passorclose" value="${bpmCrmLoan.loanTitleSpecialistProcess?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "贷款文件" />：                               <i class="fa fa-question-circle-o" title="贷款文件"></i>                                
       </label>
        <div class="col-sm-8"><input name="loanFilepath" value="${bpmCrmLoan.loanFilepath?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳审核"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="checkmoneyCashierReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmLoan.checkmoneyCashierReview?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "证明" />：                               <i class="fa fa-question-circle-o" title="证明（附件路径）"></i>                                
       </label>
        <div class="col-sm-8"><input name="checkmoneyProofpath" value="${bpmCrmLoan.checkmoneyProofpath?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "贷款金额审核" />：                               <i class="fa fa-question-circle-o" title="贷款金额审核"></i>                                
       </label>
        <div class="col-sm-8"><input name="checkmoneyLoanamountreceived" value="${bpmCrmLoan.checkmoneyLoanamountreceived?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收据编号" />：                               <i class="fa fa-question-circle-o" title="收据编号（需要校验是否重复）"></i>                                
       </label>
        <div class="col-sm-8"><input name="checkmoneyReceiptnumber" value="${bpmCrmLoan.checkmoneyReceiptnumber?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "出纳备注/备忘录"/>：</label>
        <div class="col-sm-8">
            <textarea name="checkmoneyMemo" class="form-control" required>${bpmCrmLoan.checkmoneyMemo?default("")}</textarea>
        </div>
    </div>
               
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "订单生效日"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="orderTakeEffectTime"  data-type="date"   value="${(bpmCrmLoan.orderTakeEffectTime?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "收款日"/>：</label>
        <div class="col-sm-8">
            <div class="input-group date">
                <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                <input class="form-control time-input" name="collectionTime"  data-type="date"   value="${(bpmCrmLoan.collectionTime?string('yyyy-MM-dd'))!}" data-format="yyyy-MM-dd" type="text"  required/>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "利息率" />：                               <i class="fa fa-question-circle-o" title="利息率（默认千分之八）"></i>                                
       </label>
        <div class="col-sm-8"><input name="interestRate" value="${bpmCrmLoan.interestRate?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "财务经理审核"/>：</label>
        <div class="col-sm-8">
           <@form.radio name="financeManagerReview" dictType="sys_bpm_crm_passorclose" value="${bpmCrmLoan.financeManagerReview?default('')}" />
        </div>

    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"><span style="color: red; ">*</span><@ctx.i18n text = "经理复核" />：                               <i class="fa fa-question-circle-o" title="经理复核"></i>                                
       </label>
        <div class="col-sm-8"><input name="managerReview" value="${bpmCrmLoan.managerReview?default("")}" class="form-control" type="text"  required>                                                
        </div>
     </div>
</@form.form>
<@footer>
<script type="text/javascript">
    var prefix = baseURL + "bpm/loan";
    $("#form-loan-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        var newString =$('#form-loan-edit').serialize();
        var intervalDay='';
        var orderTakeEffectTime=$("[name='orderTakeEffectTime']").val();
        var collectionTime=$("[name='collectionTime']").val();
        if(!isNullOrEmpty(orderTakeEffectTime)&&!isNullOrEmpty(collectionTime)){
            var timeSpan=new Date(collectionTime)-new Date(orderTakeEffectTime);
            intervalDay=Math.floor(timeSpan/(24*3600*1000)).toString();
        }
        var interestRate=$("[name='interestRate']").val();
        console.log("利息率",interestRate)
        var loanMoney=$("[name='loanMoney']").val();
        console.log("贷款金额",loanMoney)
        var costOfCapital=parseFloat(loanMoney)*parseInt(intervalDay)*parseFloat(interestRate);
        console.log("资金成本",costOfCapital.toFixed(4))
        console.log("赋值前对象的值为",newString)
        if(newString.includes("intervalDay")){
            newString=newString.replace("&intervalDay=",("&intervalDay="+intervalDay));
        }
        else{
            newString=newString+ "&intervalDay="+intervalDay;
        }
        if(newString.includes("costOfCapital")){
            newString=newString.replace("&costOfCapital=",("&costOfCapital="+costOfCapital.toFixed(4)));
        }
        else{
            newString=newString+ "&costOfCapital="+costOfCapital.toFixed(4);
        }
        console.log("赋值后的对象字符串的值为",newString)
        if (opt.validate.form()) {
            opt.operate.save(prefix + "/edit", newString);
        }
    }
    function isNullOrEmpty(value) {
        return value==''||value==null||value==undefined;
    }


</script>
</@footer>
</@pageTheme>
